//
//  CoachsBookRadioCell.m
//  CoachsBook
//
//  Created by huiyong li on 2022/8/20.
//

#import "CoachsBookRadioCell.h"
@interface CoachsBookRadioCell ()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIView *lineView;

@end

@implementation CoachsBookRadioCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier])
    {
        [self setViews];
        self.contentView.backgroundColor = [UIColor whiteColor];
    }
    return self;
}


- (void)setViews
{

    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 10, 120, 30)];
    self.titleLabel.font = [UIFont systemFontOfSize:16];
    self.titleLabel.textColor = rgba(51, 51, 51, 1);
    
    
    self.lefttabbut = [[UIButton alloc]initWithFrame:CGRectMake(APPwidth - 25 - (APPwidth - 30 - 30 - 120), 10, (APPwidth - 30 - 40 - 120)/2, 30)];
    [self.lefttabbut setImage:[UIImage imageNamed:@"mine_unselected"] forState:UIControlStateNormal];
    [self.lefttabbut setImage:[UIImage imageNamed:@"mine_selected"] forState:UIControlStateSelected];
    [self.lefttabbut setTitleColor:rgba(51, 51, 51, 1) forState:UIControlStateNormal];
    self.lefttabbut.titleLabel.font = [UIFont systemFontOfSize:14];
    self.lefttabbut.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 6);
    self.lefttabbut.titleEdgeInsets = UIEdgeInsetsMake(0, 6, 0, 0);
    
    self.righttabbut = [[UIButton alloc]initWithFrame:CGRectMake(APPwidth - 15 - (APPwidth - 30 - 30 - 120)/2, 10, (APPwidth - 30 - 40 - 120)/2, 30)];
    [self.righttabbut setImage:[UIImage imageNamed:@"mine_unselected"] forState:UIControlStateNormal];
    [self.righttabbut setImage:[UIImage imageNamed:@"mine_selected"] forState:UIControlStateSelected];
    [self.righttabbut setTitleColor:rgba(51, 51, 51, 1) forState:UIControlStateNormal];
    self.righttabbut.titleLabel.font = [UIFont systemFontOfSize:14];
    self.righttabbut.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 6);
    self.righttabbut.titleEdgeInsets = UIEdgeInsetsMake(0, 6, 0, 0);
    
    
    self.lineView = [[UIView alloc]initWithFrame:CGRectMake(15, 49, APPwidth-30, 1)];
    self.lineView.backgroundColor = rgba(245, 245, 245, 1);
    

    
    
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.lefttabbut];
    [self.contentView addSubview:self.righttabbut];
    [self.contentView addSubview:self.lineView];
}


-(void)cellFillWithModel:(CoachsBookInputModel *)model AndleftTitle:(NSString *)leftTitle righTitle:(NSString *)righTitle
{
    [self.lefttabbut setTitle:leftTitle forState:UIControlStateNormal];
    [self.righttabbut setTitle:righTitle forState:UIControlStateNormal];
    
    
    self.titleLabel.text = model.title;
    if ([model.content isEqualToString:@"1"]) {
        self.lefttabbut.selected = YES;
        self.righttabbut.selected = NO;
    }
    else{
        self.lefttabbut.selected = NO;
        self.righttabbut.selected = YES;
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

